package com.macro.mall.demo.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import org.elasticsearch.client.RestHighLevelClient;

/**
 * @Author：hwh
 * @Description:
 * @name：RestHighLevelClient
 * @Date：2024/10/15 19:50
 */
@Component
public class EsConfig {

    @Value("${es.host}")
    private String host;

    @Value("${es.port:8080}")
    private int port;

    @Value("${es.scheme:http}")
    private String scheme;


    @Bean
    public RestHighLevelClient restHighLevelClient() {
        return new RestHighLevelClient(RestClient.builder(new HttpHost(host, port, scheme)));
    }
}
